package com.fr.web.core.service;

import com.fr.base.FRContext;
import com.fr.base.dav.Env;
import com.fr.util.Utils;
import com.fr.web.core.WebUtils;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EnvResourceService extends NoSessionIDOPService
{
  private static EnvResourceService ENVRESOURCE_SERVICE = new EnvResourceService();

  public static EnvResourceService getInstance()
  {
    return ENVRESOURCE_SERVICE;
  }

  public boolean accept(String paramString)
  {
    return "__env_resource__".equals(paramString);
  }

  public void process(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
    throws Exception
  {
    String str = WebUtils.getHTTPRequestParameter(paramHttpServletRequest, "resource");
    ResourceService.setResourceContentType(str, paramHttpServletResponse);
    try
    {
      InputStream localInputStream = FRContext.getCurrentEnv().fileInputStream(str);
      ServletOutputStream localServletOutputStream = paramHttpServletResponse.getOutputStream();
      Utils.copyBinaryTo(localInputStream, localServletOutputStream);
      localServletOutputStream.close();
      localInputStream.close();
    }
    catch (Exception localException)
    {
    }
  }
}